/**
 * 快速查询项目
 * 
 * @param value
 */
function normalProjectQuery(value) {
	$('#projectList').datagrid('load', {
		"project.projectCode" : value
	});
}

/**
 * 打开项目编辑界面
 * 
 * @param v
 */
function openProject(v) {
	var url = "openProjectPage.do";
	if (v) {
		url += "?project.projectId=" + v;
	}
	$("#dialog").dialog("setTitle", '编辑项目').dialog('open').dialog('refresh', url);
}

/**
 * 保存项目
 * @param v
 */
function submitProject(v) {
	$('#projectForm').form('submit', {
		url : 'saveProject.do',
		onSubmit : function() {
			return true;
		},
		success : function(data) {
			if(data == "success") {				
				$.messager.alert('成功', '保存成功！', 'info', function() {
					if (v == 1) {
						$('#dialog').dialog('close');
					}
					$('#projectList').datagrid('reload');
				});
			} else if(data == "login") {
				window.location.href='index.jsp';
			}
		}
	});
}

/**
 * 打开项目跟踪界面
 * 
 */
function openPrcess() {
	var r = $('#projectList').datagrid('getSelected');
	if(r == null) {
		$.messager.alert('提示', '请选择记录！', 'info');
	} else {
		var url = "processProject.do?project.projectId="+r.projectId;
		$("#processDialog").dialog("setTitle", '项目跟踪列表').dialog('open').dialog('refresh', url);
	}
}

/**
 * 打开项目跟踪编辑界面
 */
function openProcessPage() {
	var id =$("#_processprojectId").val();
	var url = "openProjectProcess.do?projectProcess.projectId="+id;
	$("#dialogProcess").dialog("setTitle", '项目跟踪').dialog('open').dialog('refresh', url);
}

/**
 * 保存项目跟踪记录
 */
function submitProjectProcess() {
	$('#projectProcessForm').form('submit', {
		url : 'saveProjectProcess.do',
		onSubmit : function() {
			return true;
		},
		success : function(data) {
			if(data == "success") {				
				$.messager.alert('成功', '保存成功！', 'info', function() {
					$('#dialogProcess').dialog('close');
					$('#projectList').datagrid('reload');
					$('#projectProcessList').datagrid('reload');
				});
			} else if(data == "login") {
				window.location.href='index.jsp';
			}
		}
	});
}

/**
 * 打开项目指标管理界面
 */
function openIndex() {
	var r = $('#projectList').datagrid('getSelected');
	if(r == null) {
		$.messager.alert('提示', '请选择记录！', 'info');
	} else {
		var url = "indexPage.do?project.projectId="+r.projectId;
		$("#indexDialog").dialog("setTitle", '项目指标管理').dialog('open').dialog('refresh', url);
	}
}

/**
 * 创建指标，打开指标表单界面
 */
function openIndexPage() {
	var projectId = $("#_indexprojectId").val();
	var r = $('#indexProjectList').treegrid('getSelected');
	var url = "findIndex.do?index.projectId="+projectId;
	if(r != null) {
		url = url +"&index.parentId="+r.indexId;
	}
	$("#indexFormDialog").dialog("setTitle", '项目指标').dialog('open').dialog('refresh', url);
}
/**
 * 保存项目指标
 */
function submitProjectIndex() {
	$('#indexForm').form('submit', {
		url : 'saveIndex.do',
		onSubmit : function() {
			return true;
		},
		success : function(data) {
			if(data == "success") {				
				$.messager.alert('成功', '保存成功！', 'info', function() {
					$('#indexFormDialog').dialog('close');
					$('#indexProjectList').treegrid('reload');
				});
			} else if(data == "login") {
				window.location.href='index.jsp';
			}
		}
	});
}

/**
 * 调研问卷模板
 */
function openTemplate() {
	var r = $('#projectList').datagrid('getSelected');
	if(r == null) {
		$.messager.alert('提示', '请选择记录！', 'info');
	} else {
		var url = "questionnaireIndex.do?template.projectId="+r.projectId;
		$("#questionnaireDialog").dialog("setTitle", '问卷模板管理').dialog('open').dialog('refresh', url);
	}
}

function openQuestionnaireManager() {
	var r = $('#projectList').datagrid('getSelected');
	if(r == null) {
		$.messager.alert('提示', '请选择记录！', 'info');
	} else {
		var url = "naireIndex.do?naire.projectId="+r.projectId;
		$("#questionnaireManagerDialog").dialog("setTitle", '问卷管理').dialog('open').dialog('refresh', url);
	}
}